home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / archivers / xfd / developer / include / c / libraries / xfdmaster.h
C/C++ Source or Header  |  1999-05-17  |  20KB  |  497 lines

  1. #ifndef LIBRARIES_XFDMASTER_H
  2. #define LIBRARIES_XFDMASTER_H
  3.  
  4. /*
  5. **    $VER: xfdmaster.h 39.1 (24.01.1999)
  6. **
  7. **    Copyright © 1994-99 by Georg Hörmann, Dirk Stöcker
  8. **    All Rights Reserved.
  9. */
  10.  
  11. #ifndef EXEC_LIBRARIES_H
  12. #include <exec/libraries.h>
  13. #endif
  14.  
  15. /*********************
  16. *                    *
  17. *    Library Base    *
  18. *                    *
  19. *********************/
  20.  
  21. struct xfdMasterBase {
  22.   struct Library LibNode;
  23.   ULONG            xfdm_SegList;      /* PRIVATE! */
  24.   struct DosLibrary *    xfdm_DosBase;      /* May be used for I/O etc. */
  25.   struct xfdSlave *    xfdm_FirstSlave;   /* List of available slaves */
  26.   struct xfdForeMan *    xfdm_FirstForeMan; /* PRIVATE! */
  27.   ULONG            xfdm_MinBufferSize;/* (V36) Min. BufSize for xfdRecogBuffer() */
  28.   ULONG            xfdm_MinLinkerSize;/* (V36) Min. BufSize for xfdRecogLinker() */
  29.   struct ExecBase *    xfdm_ExecBase;     /* (V38.2) Cached for fast access */
  30. };
  31.  
  32. #define XFDM_VERSION    39        /* for OpenLibrary() */
  33. #define XFDM_NAME    "xfdmaster.library"
  34.  
  35. /***************************
  36. *                          *
  37. *    Object Types (V36)    *
  38. *                          *
  39. ***************************/
  40.  
  41. #define XFDOBJ_BUFFERINFO    1    /* xfdBufferInfo structure */
  42. #define XFDOBJ_SEGMENTINFO    2    /* xfdSegmentInfo structure */
  43. #define XFDOBJ_LINKERINFO    3    /* xfdLinkerInfo structure */
  44. #define XFDOBJ_SCANNODE        4    /* (V37) xfdScanNode structure */
  45. #define XFDOBJ_SCANHOOK        5    /* (V37) xfdScanHook structure */
  46. #define XFDOBJ_MAX        5    /* PRIVATE! */
  47.  
  48. /********************
  49. *                   *
  50. *    Buffer Info    *
  51. *                   *
  52. ********************/
  53.  
  54. struct xfdBufferInfo {
  55.   APTR           xfdbi_SourceBuffer;      /* Pointer to source buffer */
  56.   ULONG           xfdbi_SourceBufLen;      /* Length of source buffer */
  57.   struct xfdSlave *xfdbi_Slave;          /* PRIVATE! */
  58.   STRPTR       xfdbi_PackerName;      /* Name of recognized packer */
  59.   UWORD           xfdbi_PackerFlags;      /* Flags for recognized packer */
  60.   UWORD           xfdbi_Error;          /* Error return code */
  61.   APTR           xfdbi_TargetBuffer;      /* Pointer to target buffer */
  62.   ULONG           xfdbi_TargetBufMemType;/* Memtype of target buffer */
  63.   ULONG           xfdbi_TargetBufLen;      /* Full length of buffer */
  64.   ULONG           xfdbi_TargetBufSaveLen;/* Used length of buffer */
  65.   ULONG           xfdbi_DecrAddress;      /* Address to load decrunched file */
  66.   ULONG           xfdbi_JmpAddress;      /* Address to jump in file */
  67.   APTR           xfdbi_Special;      /* Special decrunch info (eg. password) */
  68.   UWORD           xfdbi_Flags;          /* (V37) Flags to influence recog/decr */
  69.   UWORD           xfdbi_Reserved0;      /* (V38) PRIVATE! */
  70.   ULONG           xfdbi_MinTargetLen;      /* (V38) Required length of target buffer */
  71.   ULONG           xfdbi_FinalTargetLen;  /* (V38) Final length of decrunched file */
  72.   APTR           xfdbi_UserTargetBuf;      /* (V38) Target buffer allocated by user */
  73.   ULONG           xfdbi_UserTargetBufLen;/* (V38) Target buffer length */
  74.   ULONG           xfdbi_MinSourceLen;      /* (V39) minimum source length (tested by
  75.                            master library */
  76. };
  77.  
  78. #define xfdbi_MaxSpecialLen xfdbi_Error    /* Max. length of special info */
  79.  
  80. /*********************
  81. *                    *
  82. *    Segment Info    *
  83. *                    *
  84. *********************/
  85.  
  86. struct xfdSegmentInfo {
  87.   ULONG           xfdsi_SegList;    /* BPTR to segment list */
  88.   struct xfdSlave *xfdsi_Slave;        /* PRIVATE! */
  89.   STRPTR       xfdsi_PackerName;    /* Name of recognized packer */
  90.   UWORD           xfdsi_PackerFlags;    /* Flags for recognized packer */
  91.   UWORD           xfdsi_Error;        /* Error return code */
  92.   APTR           xfdsi_Special;    /* Special decrunch info (eg. password) */
  93.   UWORD           xfdsi_RelMode;    /* (V34) Relocation mode */
  94.   UWORD           xfdsi_Flags;        /* (V37) Flags to influence recog/decr */
  95. };
  96.  
  97. #define xfdsi_MaxSpecialLen xfdsi_Error    /* Max. length of special info */
  98.  
  99. /**************************
  100. *                         *
  101. *    Linker Info (V36)    *
  102. *                         *
  103. **************************/
  104.  
  105. struct xfdLinkerInfo {
  106.     APTR    xfdli_Buffer;        /* Pointer to buffer */
  107.     ULONG    xfdli_BufLen;        /* Length of buffer */
  108.     STRPTR    xfdli_LinkerName;    /* Name of recognized linker */
  109.     APTR    xfdli_Unlink;        /* PRIVATE! */
  110.     UWORD    xfdli_Reserved;        /* Set to NULL */
  111.     UWORD    xfdli_Error;        /* Error return code */
  112.     ULONG    xfdli_Hunk1;        /* PRIVATE! */
  113.     ULONG    xfdli_Hunk2;        /* PRIVATE! */
  114.     ULONG    xfdli_Amount1;        /* PRIVATE! */
  115.     ULONG    xfdli_Amount2;        /* PRIVATE! */
  116.     APTR    xfdli_Save1;        /* Pointer to first unlinked file */
  117.     APTR    xfdli_Save2;        /* Pointer to second unlinked file */
  118.     ULONG    xfdli_SaveLen1;        /* Length of first unlinked file */
  119.     ULONG    xfdli_SaveLen2;        /* Length of second unlinked file */
  120. };
  121.  
  122. /************************
  123. *                       *
  124. *    Scan Node (V37)    *
  125. *                       *
  126. ************************/
  127.  
  128. struct xfdScanNode {
  129.   struct xfdScanNode *xfdsn_Next;    /* Pointer to next xfdScanNode or NULL */
  130.   APTR              xfdsn_Save;    /* Pointer to data */
  131.   ULONG              xfdsn_SaveLen;    /* Length of data */
  132.   STRPTR          xfdsn_PackerName;    /* Name of recognized packer */
  133.   UWORD              xfdsn_PackerFlags;/* Flags for recognized packer */
  134. };
  135.  
  136. /************************
  137. *                       *
  138. *    Scan Hook (V37)    *
  139. *                       *
  140. ************************/
  141.  
  142. struct xfdScanHook {
  143.   BOOL    (* xfdsh_Entry)();    /* Entrypoint of hook code */
  144.   APTR       xfdsh_Data;        /* Private data of hook */
  145.   ULONG       xfdsh_ToDo;        /* Bytes still to scan (READ ONLY) */
  146.   ULONG       xfdsh_ScanNode;    /* Found data right now (or NULL) (READ ONLY) */
  147. };
  148.  
  149. /********************
  150. *                   *
  151. *    Error Codes    *
  152. *                   *
  153. ********************/
  154.  
  155. #define XFDERR_OK        0x0000    /* No errors */
  156.  
  157. #define XFDERR_NOMEMORY        0x0001    /* Error allocating memory */
  158. #define XFDERR_NOSLAVE        0x0002    /* No slave entry in info structure */
  159. #define XFDERR_NOTSUPPORTED    0x0003    /* Slave doesn't support called function */
  160. #define XFDERR_UNKNOWN        0x0004    /* Unknown file */
  161. #define XFDERR_NOSOURCE        0x0005    /* No sourcebuffer/seglist specified */
  162. #define XFDERR_WRONGPASSWORD    0x0006    /* Wrong password for decrunching */
  163. #define XFDERR_BADHUNK        0x0007    /* Bad hunk structure */
  164. #define XFDERR_CORRUPTEDDATA    0x0008    /* Crunched data is corrupted */
  165. #define XFDERR_MISSINGRESOURCE    0x0009    /* (V34) Missing resource (eg. library) */
  166. #define XFDERR_WRONGKEY        0x000a    /* (V35) Wrong 16/32 bit key */
  167. #define XFDERR_BETTERCPU    0x000b    /* (V37) Better CPU required */
  168. #define XFDERR_HOOKBREAK    0x000c    /* (V37) Hook caused break */
  169. #define XFDERR_DOSERROR        0x000d    /* (V37) Dos error */
  170. #define XFDERR_NOTARGET        0x000e    /* (V38) No user target given */
  171. #define XFDERR_TARGETTOOSMALL    0x000f    /* (V38) User target is too small */
  172. #define XFDERR_TARGETNOTSUPPORTED 0x0010 /* (V38) User target not supported */
  173.  
  174. #define XFDERR_UNDEFINEDHUNK    0x1000    /* (V34) Undefined hunk type */
  175. #define XFDERR_NOHUNKHEADER    0x1001    /* (V34) File is not executable */
  176. #define XFDERR_BADEXTTYPE    0x1002    /* (V34) Bad hunk_ext type */
  177. #define XFDERR_BUFFERTRUNCATED    0x1003    /* (V34) Unexpected end of file */
  178. #define XFDERR_WRONGHUNKAMOUNT    0x1004    /* (V34) Wrong amount of hunks */
  179. #define XFDERR_NOOVERLAYS    0x1005    /* (V36) Overlays not allowed */
  180.  
  181. #define XFDERR_UNSUPPORTEDHUNK    0x2000    /* (V34) Hunk type not supported */
  182. #define XFDERR_BADRELMODE    0x2001    /* (V34) Unknown XFDREL_#? mode */
  183.  
  184. /*******************************
  185. *                              *
  186. *    Relocation Modes (V34)    *
  187. *                              *
  188. *******************************/
  189.  
  190. #define XFDREL_DEFAULT        0x0000    /* Use memory types given by hunk_header */
  191. #define XFDREL_FORCECHIP    0x0001    /* Force all hunks to chip ram */
  192. #define XFDREL_FORCEFAST    0x0002    /* Force all hunks to fast ram */
  193.  
  194. /*************************************
  195. *                                    *
  196. *    Values for xfd??_PackerFlags    *
  197. *                                    *
  198. *************************************/
  199.  
  200. /* Bit numbers */
  201. #define XFDPFB_RELOC    0    /* Relocatible file packer */
  202. #define XFDPFB_ADDR    1    /* Absolute address file packer */
  203. #define XFDPFB_DATA    2    /* Data file packer */
  204.  
  205. #define XFDPFB_PASSWORD    4    /* Packer requires password */
  206. #define XFDPFB_RELMODE    5    /* (V34) Decruncher supports xfdsi_RelMode */
  207. #define XFDPFB_KEY16    6    /* (V35) Packer requires 16 bit key */
  208. #define XFDPFB_KEY32    7    /* (V35) Packer requires 32 bit key */
  209.  
  210. #define    XFDPF